package indi.gao;

import indi.gao.bean.StudentOral;
import indi.gao.bean.StudentOralVo;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;


/**
 * org.springframework.beans.BeanUtils;
 * 1：source中和targer名称和类型一致的 source会覆盖target
 * 2：名称一致但是类型不一致会报错
 * 3：target中存在而source中不存在的属性source会保留原值
 * 4:如果source为空会报错
 * <p>
 * Assert.notNull(source, "Source must not be null");
 * Assert.notNull(target, "Target must not be null");
 */
public class beanutils {
    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {

        StudentOral studentOral = new StudentOral();
        studentOral.setAloudSecond(2424);
        studentOral.setTest(1);
        StudentOralVo studentOralVo = new StudentOralVo();
        studentOralVo.setAloudSecond(1);
        studentOralVo.setCurrentContinueReadDay(1);
        studentOralVo.setVoTest(1);
        studentOralVo.setName("gaolei");
        BeanUtils.copyProperties(studentOralVo, studentOral);
        System.out.println(studentOral.toString());
    }
}
